package com.dingwen.treasure.auth.feign;

import com.dingwen.treasure.auth.feign.fallback.TreasureManageFeignClientFallback;
import com.dingwen.treasure.base.constant.ServerConstant;
import com.dingwen.treasure.base.pojo.vo.Result;
import com.dingwen.treasure.model.entity.mybatisplus.SysElement;
import com.dingwen.treasure.model.entity.mybatisplus.SysMenu;
import com.dingwen.treasure.model.entity.mybatisplus.SysUser;
import com.dingwen.treasure.model.vo.SysMenuVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * 　TreasureManageFeignClient: manage feign 客户端 </br>
 * <p> feign 调用： auth -----> manage </p>
 * <p> feign 调用远程登录 案例</p>
 * 　@author dingwen
 * 　@date 2022/6/19
 */
@FeignClient(name = ServerConstant.TREASURE_MANAGE, fallbackFactory = TreasureManageFeignClientFallback.class)
public interface TreasureManageFeignClient {

    /**
     * 按帐户获取一个用户信息
     *
     * @param account 账户
     * @return {@link Result}<{@link SysUser}>
     */
    @GetMapping("/sys/user/feign/{account}")
    Result<SysUser> getOneByAccount(@PathVariable String account);


    /**
     * 按用户id获取系统菜单
     *
     * @param userId 用户id
     * @return {@link Result}<{@link List}<{@link SysMenu}>>
     */
    @ApiOperation(value = "根据用户Id查询菜单信息")
    @GetMapping("sys/menu/feign/{userId}")
    Result<List<SysMenu>> getSysMenusByUserId(@PathVariable Long userId);


    /**
     * 按用户id获取系统元素
     *
     * @param userId 用户id
     * @return {@link Result}<{@link List}<{@link SysElement}>>
     */
    @ApiOperation(value = "根据用户Id查询元素信息")
    @GetMapping("sys/element/feign/{userId}")
    Result<List<SysElement>> getSysElementsByUserId(@PathVariable Long userId);


    /**
     * 获取树系统菜单
     *
     * @param userId 用户id
     * @return {@link Result}<{@link List}<{@link SysMenuVo}>>
     */
    @GetMapping("sys/menu/feign/tree/{userId}")
    Result<List<SysMenuVo>> getSysMenusForTree(@PathVariable Long userId);
}
